﻿@model List<ARMS.Models.Booking>

@{
    ViewBag.Title = "Bookings";
}


@{
    ARMS.Models.Shop shop = (ARMS.Models.Shop)ViewData.Eval(ARMS.BaseClasses.Factory.CSHOP);
    string shopName = (shop != null) ? shop.name : "";
}

<h2>Booking List</h2>

<div id="shopinfo">
    Shop: @{ @Html.Raw(String.Format("<span>{0}</span>", shopName)); }
</div>

<div class="error-container">
    <h4 class="error-msg">
    @{
        @Html.Raw((string) ViewData.Eval(ARMS.BaseClasses.Factory.VERROR));
    }
    </h4>

    @Html.ValidationSummary(false, "Please correct the errors and try again.")
</div>
@{
    
    var grid = new WebGrid(source: Model,
                        defaultSort: "datestamp",  
                        rowsPerPage: 10);
   
    //grid.SortDirection = SortDirection.Ascending;
}
<div class="menu buttons">
    <button class="dialog-btn" id="new" type="button" value="Cancel">@{@Html.ActionLink("New", "MakeBooking", "Booking");}</button>
    <button class="dialog-btn" id="search" type="button" value="Cancel">@{@Html.ActionLink("Search", "Search", "Booking");}</button>
</div>
<div id="grid"> 
    @grid.GetHtml( 
        tableStyle: "grid", 
        headerStyle: "silver-bkg no-border", 
        footerStyle: "grid-bkg",
        alternatingRowStyle: "alt",
        mode: WebGridPagerModes.All,
        columns: grid.Columns(
            grid.Column("id", "#ID", style: "silver-bkg no-border"),
            grid.Column("datestamp", "Booking date", style: "grid-bkg"),
            grid.Column("servicename", "Service name", style: "grid-bkg"),
            grid.Column("customername", "Customer name", style: "grid-bkg"),
            grid.Column("note", "Description", style: "grid-bkg"),
            grid.Column("workername", "Worker", style: "grid-bkg"),
            grid.Column(header: "Scheduled", style: "grid-bkg", format: (item) =>
                {
                    if (item.active == true)
                    {
                        return Html.Raw("<text>Scheduled</text>");
                    }
                    else
                    {
                        return Html.Raw("<text style='text-align:center;'> - </text>");
                    }
                }
            ),
            grid.Column("Name", format:
                @<text>@Html.ActionLink("Edit",
                    "Detail", 
                    "Booking", 
                    new {bookingid=item.id}, 
                    new {@class="button-grd"})
                </text>)
        )
    )
</div>
<div class="footer-buttons">
    <button class="dialog-btn" id="cancel" type="button" value="Cancel">@{@Html.ActionLink("Close", "Index", "Main");}</button>
</div>